import UICore from "../../../../Core/Res/UICore";
import SdkTool from "../../../../Core/Sdk/SdkTool";
import { ViewManager } from "../../base/ViewManager";
import { GameModels } from "../../socket/GameModels";
import AbstractUIWindow from "../../window/AbstractUIWindow";
import * as fgui from "fairygui-cc";

export class ExitRoomWindow extends AbstractUIWindow {
    private callBack: Function;
    private copy: fgui.GButton;
    private confirm: fgui.GButton;
    private roomId: fgui.GTextField;
    protected getResList(): Array<string> {
        return ["Common"];
    }
    protected onInit(): void {
        this._view = UICore.createObject("Common", "ExitRoomWindow").asCom;
    }
    protected onShow(okcallback: Function): void {
        this.callBack = okcallback;
        this.copy.onClick(this.clickcopy, this);
        this.confirm.onClick(this.clickconfirm, this);
        this.roomId.text = `房间号：${GameModels.lobby.RoomId}`;
        SdkTool.ins.sdk.showBannerAd(true);
    }
    protected onClose(): void {
        SdkTool.ins.sdk.showBannerAd(false);
    }
    private clickcopy(): void {
        // this.close();
        if (!GameModels.lobby.RoomId) {
            return;
        }
        SdkTool.ins.setClipboardData(GameModels.lobby.RoomId);
    }
    private clickconfirm(): void {
        if (this.callBack) {
            this.callBack();
            this.callBack = null;
        }
        this.close();
    }
}